<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:t="http://www.pagac.cz/jsf"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
 <h:head></h:head>
 <h:body>
    <ui:composition template="/WEB-INF/templates/template-insystem.xhtml">

        <!-- Toolbar -->
        <ui:define name="toolbar-place">
            <t:toolbar>
                <t:icon iconName="home" action="goHome" label="#{msgs['toolbar.home']}" />
                <t:icon iconName="print" action="printPage" label="#{msgs['toolbar.print']}" />
                <t:separator />
                <t:icon iconName="add" action="invoice/create"
                        label="#{msgs['toolbar.add']}" sideLabel="true" />
                <t:separator />
                <!-- Granularity selection -->
                <t:icon iconName="more" action="more" backingBean="#{invoiceManager}" label="#{msgs['toolbar.more']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="moreNavLink"
                        renderedBean="#{invoiceManager.paginator}" renderedAction="moreSafe" />
                <t:icon iconName="less" action="less" backingBean="#{invoiceManager}" label="#{msgs['toolbar.less']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lessNavLink"
                        renderedBean="#{invoiceManager.paginator}" renderedAction="remainsSomething" />
                <t:separator />
                <!-- AJAX navigation -->
                <t:icon iconName="first" action="first" backingBean="#{invoiceManager}" label="#{msgs['toolbar.first']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="firstNavLink"
                    renderedBean="#{invoiceManager.paginator}" renderedAction="hasPreviousPage" />
                <t:icon iconName="prev" action="previous" backingBean="#{invoiceManager}" label="#{msgs['toolbar.previous']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="prevNavLink"
                    renderedBean="#{invoiceManager.paginator}" renderedAction="hasPreviousPage" />
                <t:textIcon>
                    <h:outputFormat value="&nbsp;#{msgs['app.paging.displayInfo']}">
                        <f:param value="#{invoiceManager.paginator.pageFirstItem + 1}" />
                        <f:param value="#{invoiceManager.paginator.pageLastItem + 1}" />
                        <f:param value="#{invoiceManager.paginator.itemsCount}" />
                    </h:outputFormat>
                    <h:outputText value=" (#{msgs['app.paging.page']} #{invoiceManager.paginator.actualPage + 1}) " />
                </t:textIcon>
                <t:icon iconName="next" action="next" backingBean="#{invoiceManager}" label="#{msgs['toolbar.next']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="nextNavLink"
                    renderedBean="#{invoiceManager.paginator}" renderedAction="hasNextPage" />
                <t:icon iconName="last" action="last" backingBean="#{invoiceManager}" label="#{msgs['toolbar.last']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lastNavLink"
                    renderedBean="#{invoiceManager.paginator}" renderedAction="hasNextPage" />
            </t:toolbar>
        </ui:define>


        <!-- Title -->
        <ui:define name="content-title">
            <h1>#{msgs["user.invoice.list.page-title"]}</h1>
        </ui:define>

        <!-- Content -->
        <ui:define name="content">
            <h:outputStylesheet name="cssTable.css" library="css" />
                <!-- Project Listing -->
                <h:dataTable id="invoiceTable"
                             value="#{invoiceManager.list}"
                             var="invoice"
                             styleClass="listing"
                             rowClasses="odd,even"
                             columnClasses="name, customerName, customerName, time, pricePerRateUnit, name"
                             rendered="#{invoiceManager.dataModelRecordsCount != '0'}">

                    <t:column  headerCssStyle="listing-header" entity="${invoice}"
                               fieldName="number" sort="true" backingBean="#{invoiceManager}"
                               label="#{msgs['user.invoice.list.number']}">
                        <h:commandLink action="#{invoiceManager.detail}">
                            #{invoice.invoiceNumber}
                        </h:commandLink>
                    </t:column>

                    <t:column  sort="false" entity="${invoice}"
                               fieldName="customer" backingBean="#{invoiceManager}"
                               label="#{msgs['user.invoice.list.forCustomer']}">
                        <h:commandLink action="#{invoiceManager.customerDetail}">
                        #{invoiceManager.rowCustomerName}
                        </h:commandLink>
                    </t:column>

                    <t:column  sort="false" entity="${invoice}"
                               fieldName="note" backingBean="#{invoiceManager}"
                               label="#{msgs['user.invoice.list.project']}">
                        <h:commandLink action="#{invoiceManager.projectDetail}">
                        #{invoiceManager.rowProjectName}
                        </h:commandLink>
                    </t:column>

                    <t:column  entity="${invoice}"
                               fieldName="dateOfIssue" backingBean="#{invoiceManager}"
                               label="#{msgs['user.invoice.list.dateOfIssue']}">
                        #{invoiceManager.dateOfIssueString}
                   </t:column>

                   <t:column entity="#{invoice}" fieldName="amount"
                              backingBean="#{invoiceManager}" sort="true"
                              label="#{msgs['user.invoice.list.amount']}">
                        #{invoice.amount} #{msgs['app.currency']}
                   </t:column>

                   <t:column entity="#{invoice}" fieldName="isPaid"
                              backingBean="#{invoiceManager}" sort="true"
                              label="#{msgs['user.invoice.list.isPaid']}">
                        #{invoiceManager.isPaidString}
                   </t:column>

                </h:dataTable>

                <f:verbatim rendered="#{invoiceManager.dataModelRecordsCount != '0'}">
                <!-- AJAX navigation -->
                <p class="statusPageInfoBox">
                    <h:commandLink id="prevLink" action="#{invoiceManager.previous}"
                                    value="&#9668; #{msgs['app.paging.nextLabel']}"
                                    rendered="#{invoiceManager.paginator.hasPreviousPage}"
                                    styleClass="prevLink">
                        <f:ajax execute="@this" render="@all" onevent="showIndicator" />
                    </h:commandLink>

                    <h:outputFormat value="&nbsp;#{msgs['app.paging.displayInfo']}&nbsp;">
                        <f:param value="#{invoiceManager.paginator.pageFirstItem + 1}" />
                        <f:param value="#{invoiceManager.paginator.pageLastItem + 1}" />
                        <f:param value="#{invoiceManager.paginator.itemsCount}" />
                    </h:outputFormat>

                    &nbsp;&nbsp;&nbsp;

                    <h:outputText value=" #{msgs['app.paging.page']} #{invoiceManager.paginator.actualPage + 1} " />

                    <h:commandLink id="nextLink" action="#{invoiceManager.next}"
                                   value="#{msgs['app.paging.nextLabel']} &#9658;"
                                   rendered="#{invoiceManager.paginator.hasNextPage}"
                                   styleClass="nextLink">
                        <f:ajax execute="@this" render="@all" onevent="showIndicator" />
                    </h:commandLink>
                </p>

            </f:verbatim>

            <f:verbatim rendered="#{(invoiceManager.dataModelRecordsCount == 0)}">
                <p class="warning-messages-noitems">
                    <h:outputFormat value="#{msgs['app.listing.no-records']}" />
                </p>
            </f:verbatim>
       </ui:define>

    </ui:composition>

</h:body>
</html>
